"""/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: TestCheckerboardWidget.cxx,v $

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http:#www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#
# This example tests the vtkCheckerboardWidget.

"""

import vtk


# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)

iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

# Create a checkerboard pipeline
image1 = vtk.vtkImageCanvasSource2D()
image1.SetNumberOfScalarComponents(3)
image1.SetScalarTypeToUnsignedChar()
image1.SetExtent(0,511,0,511,0,0)
image1.SetDrawColor(255,255,255)
image1.FillBox(0,511,0,511)

pad1 = vtk.vtkImageWrapPad()
pad1.SetInput(image1.GetOutput())
pad1.SetOutputWholeExtent(0,511,0,511,0,0)

image2 = vtk.vtkImageCanvasSource2D()
image2.SetNumberOfScalarComponents(3)
image2.SetScalarTypeToUnsignedChar()
image2.SetExtent(0,511,0,511,0,0)
image2.SetDrawColor(0,0,0)
image2.FillBox(0,511,0,511)

pad2 = vtk.vtkImageWrapPad()
pad2.SetInput(image2.GetOutput())
pad2.SetOutputWholeExtent(0,511,0,511,0,0)

checkers = vtk.vtkImageCheckerboard()
checkers.SetInput(0,pad1.GetOutput())
checkers.SetInput(1,pad2.GetOutput())
checkers.SetNumberOfDivisions(10,10,1)

checkerboardActor = vtk.vtkImageActor()
checkerboardActor.SetInput(checkers.GetOutput())

# VTK widgets consist of two parts: the widget part that handles event processing
# and the widget representation that defines how the widget appears in the scene
# (i.e., matters pertaining to geometry).
rep = vtk.vtkCheckerboardRepresentation()
rep.SetImageActor(checkerboardActor)
##rep.SetCheckerboard(checkers)

checkerboardWidget = vtk.vtkCheckerboardWidget()
checkerboardWidget.SetInteractor(iren)
checkerboardWidget.SetRepresentation(rep)

# Add the actors to the renderer, set the background and size
ren1.AddActor(checkerboardActor)
ren1.SetBackground(1, 1, 1)
renWin.SetSize(512, 512)

# record events
##recorder = vtk.vtkInteractorEventRecorder()
##recorder.SetInteractor(iren)
##recorder.SetFileName("C:/Lib/JointTrack/branches/bryan/Tests/record.log")
##recorder.Record()
##recorder.ReadFromInputStringOn()
##recorder.SetInputString(eventLog)

# render the image
#
iren.Initialize()
renWin.Render()
#  recorder.Play()

# Remove the observers so we can go interactive. Without this the "-I"
# testing option fails.
##recorder.Off()

iren.Start()




